package com.lvw.weather.city;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.trace.http.HttpTraceRepository;
import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


@EnableDiscoveryClient
@EnableCircuitBreaker
@SpringBootApplication
// alternative of use @SpringCloudApplication that instead of above 3 annotations
@EnableFeignClients(basePackages = "com.lvw.weather.forcast.web")
public class WeatherCityApplication {

	public static void main(String[] args) {
		SpringApplication.run(WeatherCityApplication.class, args);
	}

	@Bean
	public HttpTraceRepository HttpTraceRepository() {
		return new InMemoryHttpTraceRepository();
	}

	@LoadBalanced
	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}
}
